home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
FLAT.ZIP
/
FLAT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-10
|
8KB
|
291 lines
#define WIN31
#include <windows.h>
/* For the fancy looking Borland dialog box routines */
#ifdef USES_BWCC
#include <bwcc.h>
#endif
#include "flatm.h"
#pragma hdrstop
#include "flatadd.h"
#include "flatdata.h"
#include "flatfile.h"
#include "flatlist.h"
#include "flatsear.h"
#ifdef USES_MEMCHECK
/* Memory checking routines by StratosWare Corp. */
#include "\wmemchec\memcheck.h"
#endif
/*--------------------------------------------
-
- FLAT.C for Flat Windows Program
-
- A simple flat database developed to keep
- track of our Shareware sales. This code
- shows how to put together several basic
- Windows routines to build listboxes and
- dialog boxes that list and extract user
- information. Included is a linked list
- sort routine, International date format
- routines, some quick & dirty memory routines,
- and some data search routines.
-
- Dennis R. Fischer
- Denam Systems
- 1115 Madison St. NE Suite 226
- Salem, Oregon 97303
-
- CompuServe 70405,1422
-
- Developed with Borland 3.1 Compiler
-
- Free for the taking but please give credit
- where credit is do
-
----------------------------------------------*/
/*---------------------------------------------
-
- *** Special Thanks ***
-
- I would like to offer my special thanks to
- two individuals that have helped make this
- project so much easier. They are:
-
- Horst G. Brueckner
- Adelsdorf, Germany
- CompuServe 100015,1534
-
- Flavelle Ballen
- Toronto, Canada
- CompuServe 76516,23
-
- Horst developed the 'quick & dirty' memory
- manager routines (memman.c) that is used in
- the memory procedures. The complete file (memman.zip)
- can be found on CompuServe in the Microsoft
- Windows Forum
-
- Flave developed the procedures (see the 'tTaskEntry'
- structure & WndProc()) that helps break up the 'switch
- from hell'. The complete file (tswitc.zip) that explains
- the procedure can be found on CompuServe in the
- Borland Windows Forum.
-
-----------------------------------------------------*/
/*-----------------------------------------------------
-
- #defines
-
- USES_BWCC
- If you are compiling this program with a Borland
- compiler, defining USES_BWCC includes the fancy
- looking 'chiseled steel' dialog boxes
-
- USES_MEMCHECK
- If you have MemCheck by StratosWare Corp., defining
- USES_MEMCHECK will add the routines to your code.
- MemCheck is a memory checking package that checks
- for memory allocation errors. It looks for such
- things as memory overwrites, memory leakage,
- 'out-of-memory' conditions, invalid pointers,
- and etc. This is an excellent package and can be
- purchased from:
-
- StratosWare Corporation
- 1756 Plymouth Road
- Suite 1500
- Ann Arbor, MI 48105
-
- Phone: (313) 996-2944
- Fax: (313) 747-8519
- CompuServe: 70244,1372
-
-----------------------------------------------------*/
/*-----------------------------------------------------
-
- Internet EMail
-
- For those of you using Internet, we can be reached
- by addressing your mail to:
-
- Dennis R. Fischer --- 70405.1422@compuserve.com
- Horst G. Brueckner -- 100015.1534@compuserve.com
- Flavelle Ballen ---- 76516.23@compuserve.com
- StratosWare Corp. --- 70244.1372@compuserve.com
-
-----------------------------------------------------*/
#define TASKPROC LONG CALLBACK
typedef struct
{
WORD msg;
LONG (CALLBACK *fnc)(HWND, UINT, WPARAM, LPARAM);
} tTaskEntry;
TASKPROC WMCreate (HWND, UINT, WPARAM, LPARAM);
TASKPROC WMCommand(HWND, UINT, WPARAM, LPARAM);
TASKPROC WMWininichange (HWND, UINT, WPARAM, LPARAM);
LONG CALLBACK _export WndProc(HWND, UINT, WPARAM, LPARAM);
static tTaskEntry TaskList[] =
{
{WM_CREATE, WMCreate},
{WM_WININICHANGE, WMWininichange},
{WM_COMMAND, WMCommand},
{WM_NULL, DefWindowProc}
};
#pragma argsused
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
LPSTR lpszCmdLine,int nCmdShow)
{
MSG msg;
WNDCLASS wndclass;
HWND hwnd;
#ifdef USES_BWCC
static HINSTANCE hBWCC;
#endif
SetInstance(hInstance);
if (!hPrevInstance){
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = COLOR_WINDOW + 1;
wndclass.lpszMenuName = "AMENU";
wndclass.lpszClassName = "flat";
if (!RegisterClass(&wndclass))
return FALSE;
}
#ifdef USES_MEMCHECK
mc_startcheck(NULL);
#endif
#ifdef USES_BWCC
hBWCC = LoadLibrary("BWCC.DLL");
if ((UINT) hBWCC <= HINSTANCE_ERROR)
return FALSE;
#endif
hwnd = CreateWindow("flat", "Shareware Sales",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
50, 50, 350, 220,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#ifdef USES_MEMCHECK
mc_endcheck();
#endif
#ifdef USES_BWCC
FreeLibrary(hBWCC);
#endif
return msg.wParam;
} /* WinMain */
#pragma argsused
TASKPROC _export WMWininichange (HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
/* This is called each time the user changes the
WIN.INI file. We are checking for a change
in the short date (mm/dd/yy) format */
SetDateFormat();
return 0;
} /* WMWininichange */
#pragma argsused
TASKPROC _export WMCreate (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SetDateFormat();
return 0;
}
#pragma argsused
TASKPROC _export WMCommand (HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
BOOL bDoit;
switch(wParam) {
case IDM_ADD:
do{
SetWork(DoNew);
bDoit = ProcessSale(hwnd);
if (bDoit)
SaveNewSale();
}while(bDoit);
return 0;
case IDM_DELETE:
if (SetSearch(hwnd)){
SetWork(DoDelete);
if (!GetAllSearch())
SetAllSearchs(hwnd);
ShowSales(hwnd);
}
return 0;
case IDM_EDIT:
if (SetSearch(hwnd)){
SetWork(DoEdit);
if (!GetAllSearch())
SetAllSearchs(hwnd);
ShowSales(hwnd);
}
return 0;
case IDM_VIEW:
if (SetSearch(hwnd)){
SetWork(DoView);
if (!GetAllSearch())
SetAllSearchs(hwnd);
ShowSales(hwnd);
}
return 0;
case IDM_PRINT:
#ifdef USES_BWCC
BWCCMessageBox(hwnd, "Not Implemented", "Flat", MB_OK|MB_ICONINFORMATION);
#else
MessageBox(hwnd, "Not Implemented", "Flat", MB_OK|MB_ICONINFORMATION);
#endif
return 0;
case IDM_CLOSE:
PostQuitMessage(0);
return 0;
}
return 0;
} /* WMCommand */
#pragma argsused
LONG CALLBACK _export WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
int i = 0; /* index used to reference the task list */
while ((TaskList[i].msg != NULL) && (TaskList[i].msg != message))
i++;
return ((*TaskList[i].fnc)(hwnd, message, wParam, lParam));
}